package com.ruoyi.mall.config;

import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.mall.domain.bo.MallOrderBo;
import com.ruoyi.mall.domain.vo.MallOrderVo;
import com.ruoyi.mall.service.IMallOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author wolong
 * @description:
 */
@Component
public class RedissionService
{
    protected final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Resource
    private IMallOrderService mallOrderService;

    public void handleWLClueAdd(String msg)
    {
        MallOrderBo query = new MallOrderBo();
        query.setScoreMallOrderId(msg);
        MallOrderVo mallOrder = mallOrderService.queryList(query).get(0);
        if (mallOrder.getStatus() == 0)
        {
            mallOrder.setStatus(3l);
            MallOrderBo mallOrderBo = BeanUtil.toBean(mallOrder, MallOrderBo.class);
            Boolean result = mallOrderService.updateByBo(mallOrderBo);
            if (result)
            {
                logger.info("超时订单取消成功！");
            } else
            {
                logger.error("取消订单失败！");
            }
        }
    }
}
